//=============================================================================
// Sentinel Weapon Superclass
//=============================================================================
class WoEWeapon extends Weapon
	HideDropDown
	CacheExempt
	abstract
	config(WoE_Weapons);

var bool bAllowArenaMode; //True if this weapon should have infinite ammo in WoEArena, and if it should be given extra ammo by ammo lockers (false for super-weapons etc).
var bool bArenaMode; //WoE Arena - weapons given infinite ammo.

//Used by ammo packs. Adds ammo as if an ammo pickup had been given. Returns true if ammo added.
function bool AddPickupAmmo()
{
	local bool bAmmoAdded;

	if(!AmmoMaxed(0) && AmmoClass[0] != None && AmmoClass[0].Default.PickupClass != None)
	{
		bAmmoAdded = true;
		AddAmmo(class<Ammo>(AmmoClass[0].Default.PickupClass).Default.AmmoAmount, 0);
	}

	if(!AmmoMaxed(1) && AmmoClass[1] != None && AmmoClass[1].Default.PickupClass != None)
	{
		bAmmoAdded = true;
		AddAmmo(class<Ammo>(AmmoClass[1].Default.PickupClass).Default.AmmoAmount, 1);
	}

	return bAmmoAdded;
}

simulated function FillToInitialAmmo()
{
	if(!bAllowArenaMode)
		return;

	Super.FillToInitialAmmo();
}

simulated function float DesireAmmo(class<Inventory> NewAmmoClass, bool bDetour)
{
	if(!bAllowArenaMode)
		return -100;

	return Super.DesireAmmo(NewAmmoClass, bDetour);
}

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();

	if(bArenaMode)
		ArenaMode();
}

//Hack alert! Gives a false value for MaxAmmoPrimary so the ammo icon on the HUD never flashes. Needed because of hard-coded flashing ammo icon in HudCDeathMatch.DrawHudPassA
simulated function GetAmmoCount(out float MaxAmmoPrimary, out float CurAmmoPrimary)
{
	Super.GetAmmoCount(MaxAmmoPrimary, CurAmmoPrimary);
	MaxAmmoPrimary = 0;
}

//Changes ammo use to 0 for the WoE Arena mutator.
function ArenaMode()
{
	if(!bAllowArenaMode)
		return;

	if(FireMode[0] != None)
	{
		FireMode[0].AmmoPerFire = 0;
		FireMode[0].Load = 0;
	}

	if(FireMode[1] != None)
	{
		FireMode[1].AmmoPerFire = 0;
		FireMode[1].Load = 0;
	}
}

//Fixed 'access none' when weapon pickups are replaced with ammo in WoE gametypes.
function DropFrom(vector StartLocation)
{
    local int m;
	local Pickup Pickup;

    if (!bCanThrow || !HasAmmo())
        return;

    ClientWeaponThrown();

    for (m = 0; m < NUM_FIRE_MODES; m++)
    {
        if (FireMode[m].bIsFiring)
            StopFire(m);
    }

	if ( Instigator != None )
	{
		DetachFromPawn(Instigator);
	}

	Pickup = Spawn(PickupClass,,, StartLocation);
	if ( Pickup != None )
	{
    	Pickup.InitDroppedPickupFor(self);
	    Pickup.Velocity = Velocity;
        if (Instigator.Health > 0 && WeaponPickup(Pickup) != None)
            WeaponPickup(Pickup).bThrown = true;
    }

    Destroy();
}

simulated function bool FirstPersonView()
{
	return (Instigator.IsLocallyControlled() && (PlayerController(Instigator.Controller) != None) && !PlayerController(Instigator.Controller).bBehindView);
}

defaultproperties
{
     bAllowArenaMode=True
     SelectAnim="Pickup"
     PutDownAnim="PutDown"
     DisplayFOV=60.000000
     CenteredOffsetY=0.000000
     CenteredRoll=1024
     GroupOffset=154
     IconMaterial=Texture'TFMedia.Icons.WoE_Icons'
     IconCoords=(X2=80,Y2=40)
     UV2Texture=Shader'XGameShaders.WeaponShaders.WeaponEnvShader'
}
